function Template(){
    this.id=null;
    this.type_1= "*";
    this.type_2= "*";
    this.content_type= "*";
    this.content="";
    this.title="";
    this.introduction= "";
    this.create_time="0000000000000";
    this.renovate_time= "0000000000000";
    this.selected = "0"
}
Template.prototype.parse = function(data){
    this.id=data.id;
    this.type_1=data.type_1;
    this.type_2=data.type_2;
    this.introduction= data.introduction;
    this.content_type=data.content_type;
    this.title=data.title;
    this.content= data.content;
    this.selected = data.selected;
    this.create_time= new Date(parseInt(data.create_time)).toLocaleDateString()+" "+new Date(parseInt(data.create_time)).getHours()+":"+new Date(parseInt(data.create_time)).getMinutes();
    if(data.renovate_time != "")
    {this.renovate_time= new Date(parseInt(data.renovate_time)).toLocaleDateString()+" "+new Date(parseInt(data.renovate_time)).getHours()+":"+new Date(parseInt(data.renovate_time)).getMinutes();}
}
Template.prototype.serialize = function(){
    return{
        id:this.id,
        type_1:this.type_1,
        type_2:this.type_2,
        title:this.title,
        introduction:this.introduction,
        content_type:this.content_type,
        content:this.content,
        create_time:this.create_time,
        renovate_time:this.renovate_time
    }
}
// 暂时将属性存起来，做一次备份
Template.prototype.storageValue = function() {
    this.storage = this.serialize();
}

// 用备份的数据覆盖现有数据
Template.prototype.applyStorageValue = function() {
    if(this.storage) {
        this.parse(this.storage);
    }
}

// 解析json数据，返回一个对象
Template.parse = function(data) {
    var o = new Template();
    o.parse(data);
    return o;
}

// 解析json数组，返回对象数组
Template.parseList = function(list) {
    var len = list.length;
    var arr = new Array(len);
    for(var i = 0; i < len; i++) {
        arr[i] = Template.parse(list[i]);
    }
    return arr;
}
export default Template